package com.ruoyi.zhike.controller.merchant;

import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.zhike.db.domain.MerchantDetailInfo;
import com.ruoyi.zhike.merchant.service.IMerchantDetailInfoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.zhike.wrapper.MerchantDetailInfoWrapper;

/**
 * 商户详情信息Controller
 * 
 * @author ruoyi
 * @date 2024-04-17
 */
@RestController
@RequestMapping("/merchant/detailInfo")
public class MerchantDetailInfoController extends BaseController
{
    @Autowired
    private IMerchantDetailInfoService merchantDetailInfoService;

    /**
    *
    */
    @GetMapping("/extData")
    public AjaxResult extData() {
        JSONObject returnData = new JSONObject();

        return AjaxResult.success(returnData);
    }

    /**
     * 查询商户详情信息列表
     */
    @RequiresPermissions("merchant:detailInfo:list")
    @GetMapping("/list")
    public TableDataInfo list(MerchantDetailInfo merchantDetailInfo)
    {
        startPage();
        List<Map<String, Object>> list = merchantDetailInfoService.selectMerchantDetailInfoListMap(merchantDetailInfo);
        list = new MerchantDetailInfoWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 导出商户详情信息列表
     */
    @RequiresPermissions("merchant:detailInfo:export")
    @Log(title = "商户详情信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MerchantDetailInfo merchantDetailInfo)
    {
        List<MerchantDetailInfo> list = merchantDetailInfoService.selectMerchantDetailInfoList(merchantDetailInfo);
        ExcelUtil<MerchantDetailInfo> util = new ExcelUtil<MerchantDetailInfo>(MerchantDetailInfo.class);
        util.exportExcel(response, list, "商户详情信息数据");
    }

    /**
     * 获取商户详情信息详细信息
     */
    @RequiresPermissions("merchant:detailInfo:query")
    @GetMapping(value = "/{infoId}")
    public AjaxResult getInfo(@PathVariable("infoId") Long infoId)
    {
        return success(merchantDetailInfoService.selectMerchantDetailInfoByInfoId(infoId));
    }

    /**
     * 新增商户详情信息
     */
    @RequiresPermissions("merchant:detailInfo:add")
    @Log(title = "商户详情信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MerchantDetailInfo merchantDetailInfo)
    {
        return toAjax(merchantDetailInfoService.insertMerchantDetailInfo(merchantDetailInfo));
    }

    /**
     * 修改商户详情信息
     */
    @RequiresPermissions("merchant:detailInfo:edit")
    @Log(title = "商户详情信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MerchantDetailInfo merchantDetailInfo)
    {
        return toAjax(merchantDetailInfoService.updateMerchantDetailInfo(merchantDetailInfo));
    }

    /**
     * 删除商户详情信息
     */
    @RequiresPermissions("merchant:detailInfo:remove")
    @Log(title = "商户详情信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{infoIds}")
    public AjaxResult remove(@PathVariable Long[] infoIds)
    {
        return toAjax(merchantDetailInfoService.deleteMerchantDetailInfoByInfoIds(infoIds));
    }
}
